﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Urgencias.Controlador;

namespace Urgencias.Vista
{
    public partial class ListadoMedicoUC : UserControl
    {
        public ListadoMedicoUC()
        {
            InitializeComponent();
        }

        private void ListadoMedicoUC_Load(object sender, EventArgs e)
        {
            string connectionString = "Data Source=(LocalDB)\\v11.0;AttachDbFileName=|DataDirectory|\\Database.mdf;Connect Timeout=30";
            SqlConnection connection = new SqlConnection(connectionString);
            //Now, the connection string

            //That's the connection string you copied. As you can see, you have to make some changes with the quotation marks. Watch them carefully.

            using (Conexion.Instance.Con) //With this, you don't have to close the connection
            {
                
                SqlDataAdapter adapter = new SqlDataAdapter("select * from Medico", Conexion.Instance.Con);
                DataSet ds = new DataSet();
                adapter.Fill(ds, "Medico");
                GridViewMedico.DataSource = ds;
                GridViewMedico.DataMember = "Medico";
            }
        }
    }
}
